package org.opens.lambda.collector;

import org.junit.Test;
import org.opens.lambda.UserEntity;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 功能:
 *
 * @author zym
 * @Date 2021/12/20 12:00
 */
public class StreamToString {

    /**
     * 功能: 测试将List转换未指定格式的字符串(使用stream).
     */
    @Test
    public void test1() {
        List<UserEntity> list = UserEntity.getList(5);
        String collect = list.stream().map(x -> x.getSex() + "|" + x.getName()).collect(Collectors.joining(",", "[", "]"));
        System.out.println(collect);
    }

}
